package _1_Array._2021_58;

public class Main3 {
    public int translateNum (int num) {
        // write code here
        String s=String.valueOf(num);
        char[] arr=s.toCharArray();
        int[] dp=new int[s.length()+1];
        dp[0]=1;
        dp[1]=arr[0]=='0'?0:1;
        if(s.length()<=1){
            return dp[1];
        }
        for (int i=2;i<=s.length();i++){
            int n=(arr[i-2]-'0')*10+(arr[i-1]-'0');
            if (arr[i-1]=='0' && arr[i-2]=='0'){
                return 0;
            }else if (arr[i-2]=='0'){
                dp[i]=dp[i-1];
            }else  if (arr[i-1]=='0'){
                if(n>25){
                    return 0;
                }
                dp[i]=dp[i-2];
            }else if (n>25){
                dp[i]=dp[i-1];
            }else {
                dp[i]=dp[i-1]+dp[i-2];
            }
        }
        return dp[dp.length-1];

    }
}
